/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-12-19
 * Time: 下午2:33
 * To change this template use File | Settings | File Templates.
 */
Ext.define('Airways.view.customer.CustView',{
    extend:'Ext.grid.Panel',
    alias:'widget.custView',
    layout:'fit',
    autoScroll:true,
    height:'100%',
    store:'customer.CustStore',
    forceFit:true,
    initComponent: function() {
        this.dockedItems = this.buildDockedItems();
        this.bbar = this.buildBbar();
        this.columns = this.buildColumns();
        this.callParent(arguments);
    },
    buildDockedItems:function(){
        return [{
            dock: 'top',
            xtype: 'toolbar',
            items:['-',{
                xtype:'label',
                text:'客户名称:'
            },{
                xtype:'textfield',
                name:'custName'
            },'-',{
                xtype:'label',
                text:'客户电话:'
            },{
                xtype:'textfield',
                name:'custPhone'
            },'-',{
                xtype:'label',
                text:'客户类型:'
            },{
                xtype:'combo',
                name:'custType',
                queryMode:'local',
                displayField:'value',
                valueField:'key',
                value:'',
                store:Ext.create('Ext.data.Store',{
                    model:'comboxModel',
                    data:[{key:'',value:'全部'},{key:'001',value:'VIP客户'},{key:'002',value:'高富帅客户'},{key:'003',value:'白富美客户'},{key:'004',value:'纯屌丝客户'}]
                })
            },'-',{
                xtype:'button',
                iconCls:'search',
                action:'find',
                text:'查询'
            },'-',{
                xtype:'button',
                iconCls:'create',
                action:'add',
                text:'添加'
            },'-',{
                xtype:'button',
                iconCls:'update',
                text:'修改',
                disable:true,
                action:'update'
            },'-',{
                xtype:'button',
                iconCls:'delete',
                text:'删除',
                disable:true,
                action:'delete'
            },'-']
        }];
    },
    buildBbar:function(){
        return Ext.create('Ext.PagingToolbar', {
            store:'customer.CustStore',
            displayInfo: true
        });
    },
    buildColumns:function(){
        return [
            Ext.create('Ext.grid.RowNumberer'),
            {text: "客户名称",dataIndex:'custName'},
            {text: "客户编码",dataIndex:'custCode',sortable: true},
            {text: "客户类型",dataIndex:'custType',renderer:this.changeStatus,sortable: true},
            {text: "海关代码",dataIndex:'hsCode',sortable: true},
            {text: "EDI通讯码",dataIndex:'EDICode',sortable: true},
            {text: "电话",dataIndex:'phone',sortable: true},
            {text: "传真",dataIndex:'fax',sortable: true},
            {text: "电传",dataIndex:'tix',sortable: true},
            {text: "邮件",dataIndex:'email',sortable: true},
            {text: "联系人",dataIndex:'contract',sortable: true},
            {text: "地址",dataIndex:'address',sortable: true},
            {text: "级别",dataIndex:'level',sortable: true},
            {text: "最小协议退单天数",dataIndex:'limitContract',sortable: true},
            {text: "状态",dataIndex:'status'}
        ];
    },
    changeStatus:function(val) {
        if (val == 001) return "VIP客户";
        if (val == 002) return "高富帅客户";
        if (val == 003) return "白富美客户";
        if (val == 004) return "纯屌丝客户";
    }
})
